﻿// ***********************************************************************
// Assembly         : TxOsgViewer
// Author           : tian_
// Created          : 02-08-2022
//
// Last Modified By : tian_
// Last Modified On : 02-08-2022
// ***********************************************************************
// <copyright file="CreactRectAnnulusCmd.cs" company="北京腾雪科技有限责任公司">
//     Copyright © 北京腾雪科技有限责任公司 2022
// </copyright>
// <summary></summary>
// ***********************************************************************
using Osg;
using System;
using System.Drawing;
using Tx.Addins;
using Tx.OSG;
using Tx.OSG.UI;
using Tx.OSG.UI.Commands;

namespace TxOsgViewer.TestCmds
{
    /// <summary>
    /// Class CreactRectAnnulusCmd.
    /// Implements the <see cref="Tx.Addins.IExtendCommand" />
    /// </summary>
    /// <seealso cref="Tx.Addins.IExtendCommand" />
    [OsgViewCmdEnable]
    public class CreactRectAnnulusCmd : IExtendCommand
    {
        /// <summary>
        /// Executes the specified command data.
        /// </summary>
        /// <param name="cmdData">The command data.</param>
        /// <param name="message">The message.</param>
        /// <returns>CmdResult.</returns>
        public CmdResult Execute(ExtendCmdData cmdData, ref string message)
        {
            var viewWindow = cmdData.ViewWindow as IViewWindow;
            var osgObj = (viewWindow.View as IOsgView).OsgObj;

            var geom = OsgGeometryEx.CreactRectAnnulus(new Vec2f(), 100, 150, 50, 
                0, (float)Math.PI * 0.5f, (float)Math.PI / 48, Color.White.ToOsgF());
            Geode geode = geom.CreateGeode("2");
            osgObj.AddOrReplaceModel("Models", geode);
            osgObj.SetView(ViewMode.ShowAll);

            var geom2 = OsgGeometryEx.CreateBox(-100, 0, 100, 0, 100, 0, new Vec4f(1, 1, 1, 1)); 
            Geode geode2 = geom2.CreateGeode("3");
            osgObj.AddOrReplaceModel("Models", geode2);
            osgObj.SetView(ViewMode.ShowAll);

            return CmdResult.Succeed;
        }
    }
}
